import React from 'react';
import { connect } from 'dva';
import PropTypes from 'prop-types';
import {Link} from 'dva/router';
import {Button,Row,Col,Layout, Breadcrumb,Select,Icon,Input,Card,message} from 'antd';
// import reqwest from 'reqwest';
import aStyle from '../../styles/App.less'
import style from '../../styles/ResetInput.less';
import TableStyle from '../../styles/TableCss.less';
import inStyle from '../../styles/Info.less'
import {numvail,selectvail,mathvail,bankvail} from '../../utils/Validator.js'
// import {disabledStartDate,disabledEndDate} from '../../utils/Date.js'
import {role_case} from '../../models/Role.js';
import {reqwest_get,reqwest_post} from '../../utils/Reqwest.js'
class BankList extends React.Component{
	constructor(props){
		super(props);
		this.state={
			bank_cards:[]
		}
	}
	getBankCard(){
		reqwest_get('/api/users/bank_cards',{
			access_token:window.localStorage['token']
		},(data)=>{
			if(data.status=='success'){
				console.log(data)
				this.setState({bank_cards:data.list})
			}else{
				message.error(data.msg,0.3)
			}
		});
	}
	componentWillMount(){
		this.getBankCard()
		window.sessionStorage.removeItem('bank')
	}
	render(){
		const _aa = this.state.bank_cards.map((data,index,leng)=>{
			return <Card style={{width:'300px',margin:'30px 0 30px 0px'}} key={''+data.id} title={data.account} >{data.code}<Link style={{marginLeft:15}} onClick={()=>{window.sessionStorage['bank']=JSON.stringify(data)}} to={{pathname:'/app/bank_edit'}} >编辑</Link></Card>
		})
		return(
			<Layout className={`${inStyle.ncc_left_layout}`}  style={{background:'#fff'}}>
	     	<Row type='flex'>
            <Col span={7} xl={{span:7}} xs={7} style={{padding:'24px 25px 24px'}}>
              <Breadcrumb style={{fontSize:14}}>
                <Breadcrumb.Item>我的银行卡</Breadcrumb.Item>
              </Breadcrumb>
            </Col>
            <Col xl={{span :3,offset:13}} lg={{span:3,offset:13}} md={{span:3,offset:13}} sm={{span:3,offset:13}} style={{lineHeight:'60px',textAlign:'right'}}>
              <Link to={{pathname:'/app/bank'}}>添加银行卡</Link>
            </Col>
          </Row>
	     	<div  className={`${TableStyle.tb_serbor}`}>
	     	{this.state.bank_cards.length>0?_aa:<Card style={{width:'300px',margin:'30px 0 30px 0px'}}  title='银行卡' >没有你的银行卡信息<Link   to={{pathname:'/app/bank'}} >点击添加银行卡</Link></Card>}
	     	</div>
			</Layout>
		)
	}
}
export default connect()(BankList)
